﻿Imports HMSLibrary

Public Class AppointmentDataLayer
    Inherits AppointmentDataProvider

    Dim SQLQuery As String = String.Empty
    
    Public Overrides Function GetAppointments(ByVal drID As Integer, ByVal startDate As Date, ByVal endDate As Date) As System.Collections.Generic.List(Of HMSLibrary.PatientAppointment)
        Dim lst As New List(Of PatientAppointment)
        Dim objPRM(2) As Object
        objPRM(0) = drID
        objPRM(1) = startDate
        objPRM(2) = endDate
        Dim dr As IDataReader
        dr = DataCommon.db.ExecuteReader("Proc_GetPatientAppointmentList", objPRM)
        While dr.Read
            Dim app As New PatientAppointment
            app.appDataTime = dr.Item("AppDataTime")
            app.patientId = dr.Item("PatientId")
            app.PatientName = dr.Item("PatientName")
            app.AppointmentTypeName = dr.Item("AppointmentType")
            app.appConfirm = dr.Item("AppConfirm")
            lst.Add(app)
        End While
        dr.Close()
        Return lst
    End Function

    Public Overrides Function GetTodayAppointmentList(ByVal drID As Integer) As System.Collections.Generic.List(Of HMSLibrary.Lookups)

    End Function

    Public Overrides Function SaveAppointment(ByVal sender As HMSLibrary.PatientAppointment, ByVal Mode As HMSLibrary.FormAction) As Integer
        Dim objPRM(7) As Object
        objPRM(0) = sender.patientId
        objPRM(1) = DBNull.Value
        objPRM(2) = sender.consultingDoc
        objPRM(3) = sender.appDataTime
        objPRM(4) = sender.appointmentType
        objPRM(5) = sender.appointmentStatus
        objPRM(6) = sender.appConfirm
        objPRM(7) = sender.appTentative

        If Mode = FormAction.ADD Then
            DataCommon.db.ExecuteScalar("Proc_Insert_PatientAppointment", objPRM)
            CommonMessages.ShowGeneralMsg("New Appointment Created", CommonMessages.MessageTitle)
        ElseIf Mode = FormAction.EDIT Then
            'If DataCommon.db.ExecuteNonQuery( "update_tbl_ItemMaster", objPRM) = 0 Then Exit Function
            'MsgBox(CommonMessages.EditMessage, MsgBoxStyle.Information, CommonMessages.MessageTitle)
        End If
        Return True
    End Function
End Class
